package my.jwds.lcp39;

import java.util.HashMap;
import java.util.Map;

public class MinimumSwitchingTimes {

    public int minimumSwitchingTimes(int[][] source, int[][] target) {
        Map<Integer,Integer> map  = new HashMap<>();
        for (int[] ints : source) {
            for (int i : ints) {
                map.putIfAbsent(i,0);
                map.put(i,map.get(i)+1);
            }
        }
        int res = 0;
        for (int[] ints : target) {
            for (int i : ints) {
                Integer count = map.get(i);
                if (count == null || count == 0){
                    res++;
                }else{
                    map.put(i,count-1);
                }
            }
        }
        return res;

    }
}
